package router.message;

import java.io.Serializable;

public class MessageID implements Serializable {
	private static final long serialVersionUID = 1932677526080849631L;
	private final int deviceID;
	private final int compID;
	
	public MessageID(int fullID) {
		super();
		this.deviceID = fullID/256;
		this.compID = fullID%256;
	}
	
	public MessageID(int deviceID, int compID) {
		super();
		this.deviceID = deviceID;
		this.compID = compID;
	}

	public int getFullID() {
		return deviceID*256 + compID;
	}
	
	public int getDeviceID() {
		return deviceID;
	}
	
	public int getCompID() {
		return compID;
	}

	@Override
	public boolean equals(Object obj) {
		if(obj instanceof MessageID) {
			return ((MessageID) obj).compID == compID && ((MessageID) obj).deviceID == deviceID;
		} else {
			return false;
		}
	}

	@Override
	public String toString() {
		return "("+deviceID+","+compID+")";
	}
	
	
}
